package com.grass.p019lv.activity;

import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.VarietyBean;
import com.androidx.p013lv.base.bean.VarietyListBean;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.NetUtil;
import com.grass.p019lv.adapter.AdapterVariety;
import com.grass.p019lv.databinding.ActivityVarietyBinding;
import com.gyf.immersionbar.ImmersionBar;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

/* renamed from: com.grass.lv.activity.VarietyActivity */
public class VarietyActivity extends BaseActivity<ActivityVarietyBinding> implements View.OnClickListener, OnRefreshListener {
    String HTTP_TAG = "carefullyList";
    AdapterVariety adapter;

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return R.layout.activity_variety;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        ((ActivityVarietyBinding) this.binding).refresh.setOnRefreshListener(this);
        ((ActivityVarietyBinding) this.binding).refresh.setEnableLoadMore(false);
        ((ActivityVarietyBinding) this.binding).recycler.setLayoutManager(new LinearLayoutManager(getActivity()));
        this.adapter = new AdapterVariety();
        ((ActivityVarietyBinding) this.binding).recycler.setAdapter(this.adapter);
        ((ActivityVarietyBinding) this.binding).ivSearch.setOnClickListener(this);
        ((ActivityVarietyBinding) this.binding).tvBack.setOnClickListener(this);
        this.adapter.setItemListener(new ItemClickListener() {
            /* class com.grass.p019lv.activity.VarietyActivity.C29171 */

            @Override // com.androidx.p013lv.base.listener.ItemClickListener
            public void onItemClick(View view, int i) {
                if (!VarietyActivity.this.isOnClick()) {
                    Postcard withString = ARouter.getInstance().build(Constance.VARIETY_INFO_ACTIVITY).withString(Key.TXT, ((VarietyBean) VarietyActivity.this.adapter.getDataInPosition(i)).getChoiceTitle()).withInt("type", ((VarietyBean) VarietyActivity.this.adapter.getDataInPosition(i)).getChoiceId()).withString(Key.DESC, ((VarietyBean) VarietyActivity.this.adapter.getDataInPosition(i)).getDesc());
                    withString.withString("data", VarietyActivity.this.adapter.getDomain() + ((VarietyBean) VarietyActivity.this.adapter.getDataInPosition(i)).getBackground()).navigation();
                }
            }
        });
        ((ActivityVarietyBinding) this.binding).statusLayout.setOnRetryListener(new View.OnClickListener() {
            /* class com.grass.p019lv.activity.VarietyActivity.View$OnClickListenerC29182 */

            public void onClick(View view) {
                VarietyActivity.this.getInfo();
            }
        });
        getInfo();
    }

    /* access modifiers changed from: package-private */
    public void getInfo() {
        AdapterVariety adapterVariety = this.adapter;
        if (!(adapterVariety == null || adapterVariety.getData() == null || this.adapter.getData().size() <= 0)) {
            this.adapter.clear();
        }
        if (!NetUtil.isNetworkAvailable()) {
            ((ActivityVarietyBinding) this.binding).statusLayout.showNoNet();
            return;
        }
        ((ActivityVarietyBinding) this.binding).statusLayout.showLoading();
        HttpUtils.getInsatance().get(UrlManager.getInsatance().carefullyList(), new HttpCallback<BaseRes<VarietyListBean>>(this.HTTP_TAG) {
            /* class com.grass.p019lv.activity.VarietyActivity.C29193 */

            public void onLvSuccess(BaseRes<VarietyListBean> baseRes) {
                ((ActivityVarietyBinding) VarietyActivity.this.binding).statusLayout.hideLoading();
                ((ActivityVarietyBinding) VarietyActivity.this.binding).refresh.finishRefresh();
                if (baseRes.getCode() != 200) {
                    ((ActivityVarietyBinding) VarietyActivity.this.binding).statusLayout.showError();
                } else if (baseRes.getData() == null || baseRes.getData().getList() == null || baseRes.getData().getList().size() <= 0) {
                    ((ActivityVarietyBinding) VarietyActivity.this.binding).statusLayout.showEmpty();
                } else {
                    VarietyActivity.this.adapter.setDomain(baseRes.getData().getDomain());
                    VarietyActivity.this.adapter.setData(baseRes.getData().getList());
                }
            }
        });
    }

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityVarietyBinding) this.binding).toolbar).init();
    }

    public void onClick(View view) {
        if (!isOnClick()) {
            if (view.getId() == R.id.iv_search) {
                ARouter.getInstance().build(Constance.SEARCH_ACTIVITY).navigation();
            } else if (view.getId() == R.id.tv_back) {
                finish();
            }
        }
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnRefreshListener
    public void onRefresh(RefreshLayout refreshLayout) {
        getInfo();
    }

    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        super.onDestroy();
        HttpUtils.getInsatance().cancelTag(this.HTTP_TAG);
    }
}
